/* 全局样式 */
:root {
    --primary-color: #4e73df;
    --success-color: #1cc88a;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --background-color: #f8f9fc;
    --text-color: #5a5c69;
    --border-color: #e3e6f0;
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    --border-radius: 0.35rem;
    --transition: all 0.2s ease-in-out;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* 导航栏样式 */
.navbar-brand {
    font-size: 1.5rem;
    color: white !important;
}

.navbar {
    box-shadow: var(--shadow);
    z-index: 1030;
}

/* 侧边栏样式 */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 48px 0 0;
    box-shadow: var(--shadow);
    background-color: white !important;
    border-right: 1px solid var(--border-color);
}

.sidebar-sticky {
    position: relative;
    top: 0;
    height: calc(100vh - 48px);
    padding-top: 0.5rem;
    overflow-x: hidden;
    overflow-y: auto;
}

/* 主内容区样式 */
main {
    margin-top: 20px;
}

/* 卡片样式 */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: var(--transition);
    margin-bottom: 0.75rem;
    height: 100%;
}

.card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-header {
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
}

.card-body {
    padding: 0.75rem;
}

.card-footer {
    background-color: white;
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 var(--border-radius) var(--border-radius) !important;
}

/* 链接卡片特殊样式 */
.link-card {
    cursor: pointer;
    transition: var(--transition);
    min-height: 190px;
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 20px);
    margin: 0 auto;
}

.link-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.link-card .card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.link-card .card-text {
    color: var(--text-color);
    font-size: 0.9rem;
    flex-grow: 1;
}

.link-url {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
    margin-bottom: 0.5rem;
    max-width: 100%;
}

/* 徽章样式 */
.badge {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 50rem;
    font-weight: 500;
}

.badge-category {
    background-color: var(--primary-color);
    color: white;
}

.badge-tag {
    background-color: #f8f9fa;
    color: #6c757d;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
    border: 1px solid #dee2e6;
}

/* 过滤器按钮样式 */
.filter-btn {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    background-color: white;
    color: var(--text-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.filter-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 模态框样式 */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    background-color: #f8f9fc;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    background-color: #f8f9fc;
}

/* 表单样式 */
.form-control, .form-select {
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

/* 按钮样式 */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #2e59d9;
    border-color: #2653d4;
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-success:hover {
    background-color: #17a673;
    border-color: #169b6b;
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #be3327;
    border-color: #b52f24;
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #858796;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* 管理列表样式 */
.manage-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    background-color: white;
}

.manage-item:hover {
    background-color: #f8f9fc;
}

/* 响应式设计 */
@media (max-width: 767.98px) {
    .sidebar {
        top: 56px;
        height: calc(100vh - 56px);
    }
    
    main {
        margin-left: 0;
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .link-card {
        margin-bottom: 1rem;
    }
}

@media (min-width: 768px) {
    .sidebar {
        width: 250px;
    }
    
    main {
        margin-left: 250px;
    }

    .col-md-4 {
        flex: 0 0 auto;
        width: 33.333333%;
    }
    .col-md-6 {
        flex: 0 0 auto;
        width: 50%;
    }
}

@media (min-width: 992px) {
    .col-lg-4 {
        flex: 0 0 auto;
        width: 33.333333%;
    }
    .col-lg-3 {
        flex: 0 0 auto;
        width: 25%;
    }
}

@media (min-width: 1200px) {
    .col-xl-2 {
        flex: 0 0 auto;
        width: 16.666667%;
    }
    .col-xl-3 {
        flex: 0 0 auto;
        width: 25%;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 工具提示样式 */
.tooltip {
    font-size: 0.875rem;
}

/* 标签云样式 */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-cloud .badge {
    cursor: pointer;
    transition: var(--transition);
}

.tag-cloud .badge:hover {
    transform: scale(1.05);
}

/* 网站图标样式 */
.site-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    margin-right: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.site-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 14px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-icon-default {
    background: linear-gradient(135deg, var(--primary-color), #2e59d9);
}

.site-icon-image {
    background: transparent;
    box-shadow: none;
}

.site-icon img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
}

.card-header {
    padding: 0.375rem 0.75rem;
    border-bottom: 1px solid #e3e6f0;
    background-color: #eef1f8;
}

.card-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
    height: 2.8em;
}

/* 卡片操作按钮 */
.card-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    opacity: 0.7;
    transition: var(--transition);
    z-index: 10;
}

.link-card:hover .card-actions {
    opacity: 1;
}

.card-actions .btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.875rem;
    margin-left: 0.25rem;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    background-color: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.card-actions .btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 1 !important;
    background-color: rgba(255, 255, 255, 0.9) !important;
}

.card-actions .btn i {
    font-size: 0.875rem;
    line-height: 1;
}

.card-actions-sm {
    display: flex;
    gap: 4px;
}

.card-actions-sm .btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    width: 22px;
    height: 22px;
}

.card-actions {
    margin-bottom: 0.5rem;
}

.card-actions .btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    width: 22px;
    height: 22px;
    background-color: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

/* 类别折叠样式 */
.category-header {
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e3e6f0;
    margin-bottom: 1rem;
}

.category-header:hover {
    background-color: #f8f9fc;
    border-radius: 4px;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.category-header i {
    transition: transform 0.3s ease;
}

.category-header.collapsed i {
    transform: rotate(180deg);
}

.category-content {
    transition: all 0.3s ease;
}

.category-content.collapsed {
    display: none;
}

.cursor-pointer {
    cursor: pointer;
}